Introduction
The Post Code Blocker module for Prestashop provides merchants with the ability to restrict shipping to certain postcodes to either explicitly defined or partially defined postcodes. The module provides the ability to setup different post / zip code restrictions for different shipping carriers and countries. The module also provides a post code checker widget which the customer may use on the store front to check if deliveries to their postcode is possible.
Installation
The installation procedure is very much similar to most other Prestashop modules. No core changes required therefore installation is straight forward, be sure to follow the instructions below to ensure a successful installation.
- Upload the module folder to your stores
{root}/modules
folder - Once uploaded, login to your Prestashop Back Office and head over to the Modules section
- Search for the module and click Install
- After a successful installation, the module configuration screen is presented to you. More details on this in the next section
Configuration
The module configuration allows you to edit settings related to the module. The module configuration screen is displayed immediately after a successful installation or can be accessed later using the configure link in the modules list.
The main configuration screen you will be presented with is organised under 3 tabs; General, Postcodes and Widget.
General
Lets take a look at the the options available under the general tab.
Filter delivery options during checkout?
When this option is enabled, carriers which are not available for delivery to the customer post code will not be displayed during checkout. In the event that no carriers are available at all during checkout, Prestashop will display a message informing the customer that delivery to their address is not possible.
Message
If the filtering of delivery options is disabled and the customer attempts to place an order to a blocked postcode, the message you provide here will be displayed to the customer and the customer will be unable to finalise their order.
Post Codes
The postcodes tab is where you will define the list or ranges of postcodes that should be blocked or allowed for each carrier / country combination. Therefore each carrier may have it’s own unique set of blocked or allowed postcodes. To get started, select the carrier and country as shown below:
After you have selected the carrier and country, options for blocking post codes will appear as shown below:
The first option we must set is the Filter Mode option. You have the following two options:
Block deliveries to postcodes I define
Any postcodes you add will be blocked during checkout. Choose this option if you wish to create a list of postcodes which you cannot deliver to.
Allow deliveries to postcodes I define
Only postcodes you add will be allowed during checkout. Choose this option if you wish to create a list of postcodes which you can deliver to, any postcode not in this list will be blocked.
Add Postcode
On the right hand side you can start adding your post codes to your list. In the postcode field, enter the post code you wish to add to your list, for example 1234-AA or BB2 6SS.
Wild cards
Wild cards can be used to denote a match for any sequence of numbers or characters. For example, if you wish to block all post codes starting with the characters BB then you can enter BB* into the postcode field.
Regular Expressions
For more advanced postcode pattern matching you may also enter a regular expression. Only postcodes matching the regular expression and evaluating to true will be blocked or allowed (depending on your filter mode).
Numeric Ranges
The module also allows you to block numeric postcode ranges, for instance : block all postcodes between 1000 and 2999. Simply enter the range start and range end into the respective Range Start and Range End Field
Import CSV
The final method available for defining your list of postcodes is the import option which allows you to import a list of postcodes from a CSV file format.
Widget
The module includes a feature which allows you to display a postcode checker widget for your customers to use in your store front, either on your homepage, on a CMS page or a custom location in your theme template files.
The widget tab allows you to set it up for use with the following two options:
Display widget on homepage
When enabled the module will be displayed on the homepage. You can adjust the position in the design section of the Prestashop back office
where you can rearrange the position of hooks. The postcode checker widget hook is displayed under the Display Home hook.
Allow customers to select carrier
When enabled the widget will also display a drop down allowing the customer to select which carrier to check the postcode against.
Custom Widget Placement
Although the module allows you to display the postcode checker widget on the homepage, it also allows you place it anywhere else within your site via the use of hooks.
Hooks in template files
Place the following hook (Prestashop 1.7) in any of your template files and the the widget will be displayed at that specific location:
{widget name='postcoblocker' hook='pcb_postcodechecker_widget'}
For Prestashop 1.6 you can place the following hook in your template files:
{Hook h='pcbPostcodeCheckerWidget'}
Hooks in CMS pages content
You may also display the widget in the content of a CMS page, for example a delivery information page. To do so, simply place the following short code in your CMS content:
[postcodeblocker]
The widget will now be displayed at the location in the content where you placed the short code.